Find all constant/method types per class at once#4737
Merged
ondrejmirtes merged 6 commits intophpstan:2.1.xfrom Jan 26, 2026
Merged
Find all constant/method types per class at once#4737ondrejmirtes merged 6 commits intophpstan:2.1.xfrom
ondrejmirtes merged 6 commits intophpstan:2.1.xfrom
Conversation
Collaborator
|
This pull request has been marked as ready for review. |
Contributor
Author
|
hmm maybe this caching should happen in |
Member
|
No, I don't think so. Please wait until I look at the code. |
ondrejmirtes
requested changes
Jan 9, 2026
|
|
||
| /** @var array<string, array<string, Type|null>> */ | ||
| /** @var array<lowercase-string, array<lowercase-string, array{ClassMethod, string}>> */ | ||
| private array $stubbedMethodNodes = []; |
Member
There was a problem hiding this comment.
I don't follow, what's the difference between methodNodes and stubbedMethodNodes?
I'm probably slower than usual, you know, Friday morning, heavy snowing outside etc. 😊
Contributor
Author
There was a problem hiding this comment.
I had the impression based on the previous implementation that we should only remember the requested types.
but it seems thats not the case. simplified it now
…ols not applicable for the current php version
Member
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
before this PR we read/ast-traversed every stub file only until we found the single symbol we were searching for.
after something was found, traversal stopped and we returned early.
this means we e.g. see the same file beeing read/php-parsed/ast-traversed from the filesystem multiple times, when e.g. multiple constants of the same class are unkown or a mix of constants and methods are unknown.
see a phpstan-doctrine example run:
after this PR we remember all contained symbols within a stub file on the first read/parse/ast-traversal.
when later requested we can easily lookup whether a stub for a given method or constant exists, without the need to read/parse the stub file over and overr again.